﻿using FictionsDownload.DAL;
using FictionsDownload.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FictionsDownload.BLL
{
    class Folder: BaseBLL
    {
        public bool Add(FolderModel folder)
        {
            //校验，首先，有Id就是个错误，不能添加，只能更新
            if (folder.AutoId != 0)
            {
                return false;
            }
            //校验名字是否重复
            if (GetList<FolderModel>(f => f.Name == folder.Name).Any())
            {
                return false;
            }
            //保存
            dal.Insert(folder);
            return true;
        }
        public void Delete(FolderModel folder)
        {
            folder.Delete(dal);
        }
        public void Update(FolderModel folderModel)
        {
            folderModel.ActiveTime = DateTime.Now;
            dal.Update(folderModel);
        }
    }
}
